﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using InformationSystem.BLL.Core.Model;
using System.Collections;
using InformationSystem.BLL.Core.Service;
using Ext.Net;

namespace InformationSystem.WebSite.Module.MailMgr
{
    public partial class MailContentView : BasePage
    {
        public IInformationService InformationService { get; set; }
        protected LoginUser user;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["mailid"] == null) return;
            int mailid = 0;
            if (!int.TryParse(Request.QueryString["mailid"], out mailid)) return;
            user = (LoginUser)Session["LoginUser"];
            Mail mail = InformationService.GetMailDetailByID(mailid, user.UserID);
            if (mail.Msg != string.Empty)
            {
                X.Msg.Show(new MessageBoxConfig
                {
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.INFO,
                    Title = "信息",
                    Message = mail.Msg
                });
                return;
            }
            this.hdnmailid.Value = mailid.ToString();
            this.lbSubject.Text = mail.MailSubject;
            this.lbSender.Text = string.Format("{0}[{1}]", mail.SendUserName, mail.SendUserID);
            this.lbRecvUser.Text = mail.RecvString;
            this.lbSendTime.Text = mail.SendTime.ToString("yyyy-MM-dd HH:mm:ss");
            this.txtContent.Text = mail.Content;
            if (mail.AttachmentList.Count == 0) Panel4.Hidden = true;
            this.ObjHolder1.Items.Add("Attachments", mail.AttachmentList);
        }

        protected override bool CommitPermissionCheck()
        {
            throw new NotImplementedException();
        }
    }
}